package com.compus_help.service.impl;

import com.compus_help.Mapper.OrderCategoryMapper;
import com.compus_help.entity.Pojo.OrderCategory;
import com.compus_help.entity.VO.OrderCategoryVO;
import com.compus_help.service.studentOrderCategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;

@Service
public class studentOrderCategoryServiceImpl implements studentOrderCategoryService {

    @Autowired
    private OrderCategoryMapper orderCategoryMapper;
    public List<OrderCategoryVO> getOrderCategoryList() {
    // 查询启用状态的分类
    List<OrderCategory> categories = orderCategoryMapper.selectEnabledCategories();

    // 转换为 VO 对象
        if (categories == null || categories.isEmpty()) {
            return Collections.emptyList();
        }

        List<OrderCategoryVO> result = new ArrayList<>();
        for (OrderCategory category : categories) {
            if (category != null) {
                OrderCategoryVO vo = new OrderCategoryVO();
                vo.setCategoryId(category.getCategoryId());
                vo.setCategoryName(category.getCategoryName());
                vo.setStatus(category.getStatus());
                vo.setCreateTime(category.getCreateTime());
                vo.setUpdateTime(category.getUpdateTime());
                result.add(vo);
            }
        }
        return result;
    }

}
